package com.pzh.assignment.controller;

import com.pzh.assignment.common.bean.Result;
import com.pzh.assignment.common.shiro.ShiroUtils;
import com.pzh.assignment.entity.Role;
import com.pzh.assignment.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author pengzhihao
 * @since 2022-04-05
 */
@RestController
@RequestMapping("/menus")
public class MenuController {

    @Autowired
    IMenuService menuService;

    @GetMapping
    public Result getMenus(){
        //获取当前用户角色
        Role role = ShiroUtils.getProfile().getRole();
        //获取菜单配置
        List<Map<String, Object>> menusMapList = menuService.getMenusByRole(role);
        return Result.success(menusMapList);
    }

}
